import cv2 as cv
import numpy as np
img = cv.imread('../../data/j.png',0)
kernel=np.ones((5,5),np.uint8)
# equal to dilation-erosion
gradient =cv.morphologyEx(img,cv.MORPH_GRADIENT,kernel)
# dilation-erosion
erosion =cv.erode(img,kernel,iterations=1)
dilation =cv.dilate(img,kernel,iterations=1)
dme = dilation-erosion
# merge all imgs on horizontal direction
res =np.hstack((img,gradient,dme))
cv.imshow('res',res)
cv.waitKey(0)
cv.destroyAllWindows()